<?php
class shop extends base{
	private $_table = __CLASS__;
	private $arrField = array('shop_id', 'name', 'keywords', 'start_time', 'end_time', 'region_id', 'type', 'user_id', 'is_new', 'is_best', 'is_payout', 'tag', 'thumb', 'img', 'content', 'sort', 'add_time', 'multi', 'send_time', 'brief', 'is_show');
    function get_info($uid, $arrField=array()){
    	$arrField = !empty($arrField)?$arrField:$this->arrField;
        $field = implode(',', $arrField);
        $sql = 'SELECT '.$field.' FROM '.$this->table($this->_table).' WHERE shop_id='.$uid;
        return $this->db->getRow($sql);
    }

    function get_list($start, $size, $arrField = array()){
    	$arrField = !empty($arrField)?$arrField:$this->arrField;
    	$field = implode(',', $arrField);
    	return $this->db->getAll('SELECT '.$field.' FROM '.$this->table($this->_table).' ORDER BY shop_id ASC LIMIT '.$start.', '.$size);
    }

    function add($arrData=array(), $where = null){
    	foreach ($this->arrField as $key => $value){
    		if(!isset($arrData[$value])){
    			unset($arrData[$value]);
    		}
    	}
    	return $this->db->exec($this->table($this->_table), $arrData, $where);
    }
    
    function del($id){
    	if(!$id)return false;
    	$sql = 'DELETE FROM '.$this->table($this->_table).' WHERE shop_id='.$id;
    	return $this->db->query($sql);
    }
}
?>